alpha = 0.01
for i in range(20000): 
    sigma_w0 = 0
    sigma_b = 0
    for xx, yy in zip(x, y_target_data): #循环取训练集中的一个数据
        diff =  _y(xx)- yy
        sigma_w0 = sigma_w0 + diff * xx #求和
        sigma_b = sigma_b + diff * 1.0  #求和
    w0 = w0 - alpha * sigma_w0 / m #更新w0权重
    b =  b - alpha * sigma_b / m  #更新b权重
print("w0=",w0,"  b=",b) 
# 可视化
plt.plot(x, y_target_data, 'g*') 
plt.plot(x, w0 * x + b, 'r') 
plt.show()
